package com.portal.cwegportal.mapper;

import com.portal.cwegportal.input.newscollege.GetHomePageNewsCollegeInput;
import com.portal.cwegportal.model.NewsCollege;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

@org.apache.ibatis.annotations.Mapper
@Repository
public interface NewsCollegeMapper extends Mapper<NewsCollege> {

    @Select(" select distinct n.* from news_college n  inner join release_scope r on r.key_id=n.id and INSTR(#{orgPathIDs},r.publishing_department_id)  where n.is_deleted=0 and n.status=1  and n.publish_type=#{publishType} order by n.gmt_create desc limit #{limit} ")
    List<NewsCollege> selectBylimit(GetHomePageNewsCollegeInput input);
   // id in(#{inputKeyId}) and
    @Select("select distinct n.* from news_college n inner join release_scope r on r.key_id=n.id and INSTR(#{orgPathIDs},r.publishing_department_id)  where n.is_deleted=0 and n.status=1 and n.category=2 and n.publish_type=#{publishType} order by n.gmt_create desc limit #{limit} ")
    List<NewsCollege> selectPicBylimit(GetHomePageNewsCollegeInput input);

    @Select(" select distinct n.* from news_college n  inner join release_scope r on r.key_id=n.id  where n.is_deleted=0 and n.status=1  and n.publish_type=#{publishType} order by n.gmt_create desc limit #{limit} ")
    List<NewsCollege> selectAdminBylimit(GetHomePageNewsCollegeInput input);
    // id in(#{inputKeyId}) and
    @Select("select distinct n.* from news_college n inner join release_scope r on r.key_id=n.id   where n.is_deleted=0 and n.status=1 and n.category=2 and n.publish_type=#{publishType} order by n.gmt_create desc limit #{limit} ")
    List<NewsCollege> selectAdminPicBylimit(GetHomePageNewsCollegeInput input);
}
